﻿using System;
using System.IO;
using Icms.Core.Repository;
using Icms.Core.Service;
using File = Icms.Core.Model.File;

namespace Icms.Service
{
    public class FileService : CrudService<File>, IFileService
    {
        private readonly IFileManagerService fileManagerService;

        public FileService(IRepo<File> repo, IFileManagerService fileManagerService)
            : base(repo)
        {
            this.fileManagerService = fileManagerService;
        }

        public override Guid Create(File o)
        {
            o.Bytes = fileManagerService.GetBytes(o.Name);
            return base.Create(o);
        }

    }
}